<script setup lang='ts'>
  import { onMounted, reactive, ref } from 'vue';
  import { gamesApi } from '@/api/controller';
  import { Toastloading } from '@/utils/public';
  import configForm from './configForm.vue';
  import xmImage from '@/components/xmImage/index.vue';
  // import Pagination from "@/components/Pagination/index.vue";
  const configFormRef = ref();
  const action = reactive({
    total:0,
    list:[] as any[],
  })
  const listQuery = reactive({
    page:1,
    limit:20,
  })
  const sendTypeArr = [
    {type:1,text:'娱乐积分'},
    {type:2,text:'金豆'},
    {type:3,text:'头像框/座驾/进场特效'},
  ]
  const stateList = [
    {type:1,text:'显示'},
    {type:2,text:'不显示'},
  ]
  const handleSerach = ()=>{
    getList()
  }
  const getList = async()=> {
    const loading = Toastloading()
    const res = await gamesApi.getdaysign()
    loading.close()
    const { data=[], total=0 } = res.data
    action.total = total
    action.list = data
  }
  const handleForm = (row:any = {})=>{
    configFormRef.value.openDialog({
      sendTypeArr,
      stateList,
      ...row
    })
  }
  onMounted(()=>{
    getList()
  })
</script>

<template>
  <div class="xm-content">
    <div class="xm-headTab">
      <div class="labelBox">
        <div class="labelItem">
          <el-button type="primary" @click="handleSerach">刷新</el-button>
          <!-- <el-button type="primary" @click="handleForm()">新增配置</el-button> -->
        </div>
      </div>
    </div>
    <el-table
      class="xm-main xm-TableCenter"
      :data="action.list"
      border>
      <el-table-column width="80" prop="id" label="ID" />
      <el-table-column min-width="100" prop="sigin_day" label="签到日期" />
      <el-table-column width="120" prop="pic" label="签到图片">
        <template #default="scoped">
          <xmImage :src="scoped.row.pic" :list="[scoped.row.pic]" /> 
        </template>
      </el-table-column>
      <el-table-column min-width="120" prop="send_type" label="奖励类型">
        <template #default="scoped">
          {{ sendTypeArr.find(res=>res.type == scoped.row.send_type)?.text || '' }}
        </template>
      </el-table-column>
      <el-table-column min-width="120" prop="send_num" label="奖励数量" />
      <el-table-column min-width="100" prop="send_id" label="奖励商品ID" />
      <!-- <el-table-column min-width="100" prop="status" label="展示状态">
        <template #default="scope">
          <el-tag>{{ ['','显示','不显示'][scope.row.status] }}</el-tag>
        </template>
      </el-table-column> -->
      <el-table-column fixed="right" width="180" label="操作">
        <template #default="scope">
          <el-button @click="handleForm(scope.row)" type="primary">修改配置</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- <Pagination v-show="action.total > 0" :total="action.total" v-model:page="listQuery.page"
      v-model:limit="listQuery.limit" @pagination="getList" /> -->
    <configForm @update-list="getList" ref="configFormRef" />
  </div>
</template>